<template>
    <div>
        <el-row :gutter="20">
            <el-col :span="8">
                <el-card shadow="hover" class="mgb20" style="height:225px;">
                    <div class="user-info">
                        <img :src="loginTeacher.pic" class="user-avators" alt />
                        <div class="user-info-cont">
                            <div class="user-info-name">{{loginTeacher?loginTeacher.name:''}}</div>
<!--                            <div>{{ role }}</div>-->
                        </div>
                    </div>
                    <div class="user-info-list">
                        登录时间：
                        <span>{{loginTeacher.loginTime.toLocaleString().replace(/T/g, ' ').replace(/\.[\d]{3}Z/, '')}}</span>
                    </div>
                </el-card>
            </el-col>
            <el-col :span="16">
                <el-row :gutter="20" class="mgb20">
                    <el-col :span="8">
                        <el-card shadow="hover" :body-style="{ padding: '0px' }">
                            <div class="grid-content grid-con-1">
                                <i class="el-icon-s-platform grid-con-icon"></i>
                                <div class="grid-cont-right">
                                    <div class="grid-num">{{classesCount}}</div>
                                    <div>班级数量</div>
                                </div>
                            </div>
                        </el-card>
                    </el-col>
                    <el-col :span="8">
                        <el-card shadow="hover" :body-style="{ padding: '0px' }">
                            <div class="grid-content grid-con-2">
                                <i class="el-icon-s-custom grid-con-icon"></i>
                                <div class="grid-cont-right">
                                    <div class="grid-num">{{teacherCount}}</div>
                                    <div>讲师人数</div>
                                </div>
                            </div>
                        </el-card>
                    </el-col>
                    <el-col :span="8">
                        <el-card shadow="hover" :body-style="{ padding: '0px' }">
                            <div class="grid-content grid-con-3">
                                <i class="el-icon-reading grid-con-icon"></i>
                                <div class="grid-cont-right">
                                    <div class="grid-num">{{courseCount}}</div>
                                    <div>课程数量</div>
                                </div>
                            </div>
                        </el-card>
                    </el-col>
                </el-row>
                <el-row :gutter="20" class="mgb20">
                    <el-col :span="8">
                        <el-card shadow="hover" :body-style="{ padding: '0px' }">
                            <div class="grid-content grid-con-4">
                                <i class="el-icon-user-solid grid-con-icon"></i>
                                <div class="grid-cont-right">
                                    <div class="grid-num">{{studentCount}}</div>
                                    <div>学生人数</div>
                                </div>
                            </div>
                        </el-card>
                    </el-col>
                    <el-col :span="8">
                        <el-card shadow="hover" :body-style="{ padding: '0px' }">
                            <div class="grid-content grid-con-5">
                                <i class="el-icon-message grid-con-icon"></i>
                                <div class="grid-cont-right">
                                    <div class="grid-num" >{{noticeCount}}</div>
                                    <div>消息通知</div>
                                </div>
                            </div>
                        </el-card>
                    </el-col>
                    <el-col :span="8">
                        <el-card shadow="hover" :body-style="{ padding: '0px' }">
                            <div class="grid-content grid-con-6">
                                <i class="el-icon-location grid-con-icon"></i>
                                <div class="grid-cont-right">
                                    <div class="grid-num"></div>
                                    <div>登录次数</div>
                                </div>
                            </div>
                        </el-card>
                    </el-col>
                </el-row>
            </el-col>
        </el-row>
    </div>
</template>

<script>
    export default {
        name: "ManageIndexView",
        data() {
            return {
                loginTeacher:JSON.parse(window.localStorage.getItem("loginTeacher")),
                classesCount:[],
                teacherCount:[],
                courseCount:[],
                studentCount:[],
                noticeCount:[],
            };
        },
        created() {
            this.handleClassesCount();
            this.handleTeacherCount();
            this.handleCourseCount();
            this.handleStudentCount();
            this.handleNoticeCount();
        },
        methods: {
            //班级总数
            handleClassesCount() {
                this.$axios.get("http://localhost:8080/manage/classes/total").then(response => {
                    this.classesCount = response.data.data;
                });
            },
            //教师总数
            handleTeacherCount() {
                this.$axios.get("http://localhost:8080/manage/teacher/total").then(response => {
                    this.teacherCount = response.data.data;
                });
            },
            //课程总数
            handleCourseCount() {
                this.$axios.get("http://localhost:8080/manage/course/total").then(response => {
                    this.courseCount = response.data.data;
                });
            },
            //学生总数
            handleStudentCount() {
                this.$axios.get("http://localhost:8080/student/total").then(response => {
                    this.studentCount = response.data.data;
                });
            },
            //通知总数
            handleNoticeCount() {
                this.$axios.get("http://localhost:8080/manage/notice/total").then(response => {
                    this.noticeCount = response.data.data;
                });
            },
        }
    }

</script>

<style scoped>
    .el-row {
        margin-bottom: 20px;
    }

    .grid-content {
        display: flex;
        align-items: center;
        height: 100px;
    }

    .grid-cont-right {
        flex: 1;
        text-align: center;
        font-size: 14px;
        color: #999;
    }

    .grid-num {
        font-size: 30px;
        font-weight: bold;
    }

    .grid-con-icon {
        font-size: 50px;
        width: 100px;
        height: 100px;
        text-align: center;
        line-height: 100px;
        color: #fff;
    }
    .grid-con-1 .grid-con-icon {
        background: rgb(45, 140, 240);
    }

    .grid-con-1 .grid-num {
        color: rgb(45, 140, 240);
    }

    .grid-con-2 .grid-con-icon {
        background: rgb(100, 213, 114);
    }

    .grid-con-2 .grid-num {
        color: rgb(45, 140, 240);
    }

    .grid-con-3 .grid-con-icon {
        background: rgb(242, 94, 67);
    }

    .grid-con-3 .grid-num {
        color: rgb(45, 140, 240);
    }
    .grid-con-4 .grid-con-icon {
        background: rgb(216,191,216);
    }

    .grid-con-4 .grid-num {
        color: rgb(45, 140, 240);
    }
    .grid-con-5 .grid-con-icon {
        background: rgb(255,0,0);
    }

    .grid-con-5 .grid-num {
        color: rgb(45, 140, 240);
    }
    .grid-con-6 .grid-con-icon {
        background: rgb(240,230,140);
    }

    .grid-con-6 .grid-num {
        color: rgb(45, 140, 240);
    }
    .user-info {
        display: flex;
        align-items: center;
        padding-bottom: 20px;
        border-bottom: 2px solid #ccc;
        margin-bottom: 20px;
    }

    .user-avators {
        width: 120px;
        height: 120px;
        border-radius: 50%;
    }

    .user-info-cont {
        padding-left: 50px;
        flex: 1;
        font-size: 14px;
        color: #999;
    }

    .user-info-cont div:first-child {
        font-size: 30px;
        color: #222;
    }

    .user-info-list {
        padding-left: 0px;
        font-size: 14px;
        color: #999;
        line-height: 25px;
    }

    .user-info-list span {
        margin-left: 70px;
    }

    .mgb20 {
        margin-bottom: 20px;
    }

    .todo-item {
        font-size: 14px;
    }

    .todo-item-del {
        text-decoration: line-through;
        color: #999;
    }
    .schart {
        width: 100%;
        height: 300px;
    }
</style>